package com.chushouya.order.constants;

import com.general.framework.core.enums.IEnum;
import com.general.framework.core.lang.Strings;

import java.util.Objects;

/**
 * 付款方式枚举
 */
public enum PaymentStatusEnum implements IEnum<Integer> {

    //支付成功
    SUCCESS(1, "支付成功"),
    //支付失败
    FAIL(2, "支付失败"),
    //支付中
    PROCESSING(0, "支付中");

    private Integer value;

    private String desc;

    PaymentStatusEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String getDesc(Integer value) {
        for (PaymentStatusEnum thisEnum : PaymentStatusEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum.desc;
            }
        }
        return Strings.EMPTY;
    }

    public static PaymentStatusEnum get(Integer value) {
        for (PaymentStatusEnum thisEnum : PaymentStatusEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum;
            }
        }
        return null;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.desc;
    }
}
